package jdbc;

import java.sql.*;

public class JDBCDemo6 {
    public static void main(String[] args) {
        try (Connection connection = DBUtil.getConnection()) {
            Statement statement = connection.createStatement();
            String sql = "select c.name ,c.floor ,t.name ,t.salary " +
                    "from class as c " +
                    "join teacher as t on c.teacher_id=t.id ";
            ResultSet resultSet = statement.executeQuery(sql);
            while (resultSet.next()) {
                String cname = resultSet.getString("c.name");
                String cfloor = resultSet.getString("c.floor");
                String tname = resultSet.getString("t.name");
                String tsalary = resultSet.getString("t.salary");
                System.out.println(cname + "," + cfloor + " ," + tname + " ," + tsalary);

            }


        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
